package com.xayy.mgt.controller;

import cn.kawins.base.result.ResultBody;
import cn.kawins.mybatis.base.BaseController;
import cn.kawins.spring.mvc.validator.Group;
import com.xayy.mgt.model.NodeParamInfo;
import com.xayy.mgt.service.NodeParamInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 装备画像节点参数
 * 
 * @author plq
 */
@RestController
@RequestMapping(value = "/nodeParamInfo1")
@Api(tags = "装备画像节点参数(右侧关系)")
public class NodeParamInfoController extends BaseController<NodeParamInfo> {

    @Autowired
    private NodeParamInfoService nodeParamInfoService;

    @PostMapping
    @ApiOperation(value = "新增/修改", httpMethod = "POST", response = String.class, notes = "装备画像节点参数-新增/修改")
    public ResultBody add(@Validated(Group.Insert.class) @RequestBody NodeParamInfo nodeParamInfo) {
        return nodeParamInfoService.addOrUpdate(nodeParamInfo).body();
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除", httpMethod = "DELETE", response = String.class, notes = "装备画像节点参数-删除")
    public ResultBody delete(@PathVariable Long id) {
        int i = nodeParamInfoService.deleteById(id);
        if (i > 0) {
            return ResultBody.success("删除成功");
        }
        return ResultBody.failed("删除失败");
    }

    @GetMapping("/getParams/{nodeId}")
    @ApiOperation(value = "根据节点id查询节点参数信息", httpMethod = "GET", response = NodeParamInfo.class, notes = "装备画像节点参数-根据id查询")
    public ResultBody getParams(@PathVariable Long nodeId) {
        return nodeParamInfoService.getParams(nodeId).body();
    }

}
